<?php

class pegawaibase extends CI_Controller {

    //-- init base variable
    protected $arrRuleTp = array();
    protected $strMenuCd;

    public function __construct() {
        //-- clear cache
        $this->clearCache();
        //-- load basic controller
        parent::__construct();
//        if ((($this->session->userdata('session_dokter')) || ($this->session->userdata('session_peg_poli')) || ($this->session->userdata('session_ad_obat'))) == FALSE) {
//            redirect('login/loginpegawai');
//        }
         if (($this->session->userdata('session_pegawai'))  == FALSE) {
            redirect('login/loginpegawai');
        }
        //-- load app data
        $this->baseLoadApp();
        //-- load view app data
        $this->baseViewApp();
    }

    /*
     * Method pengolah base load
     * diperbolehkan untuk dioverride pada class anaknya
     */

    protected function baseLoadApp() {
        //-- load themes (themes default : default)
        $this->smarty->load_themes("default-pegawai");
        //-- load base models
        //-- load javascript
        $this->smarty->load_javascript("resource/js/jquery/jquery-1.4.2.min.js");
        $this->smarty->load_javascript("resource/js/jquery.custom/jquery-ui-1.8.11.custom.min.js");
        $this->smarty->load_javascript("resource/js/jquery.custom/jquery.tabs.js");
        $this->smarty->load_javascript("resource/js/jquery.treeview/jquery.treeview.js");
        $this->smarty->load_javascript("resource/js/jquery.dropdown/dropdown.menu.js");
        $this->smarty->load_javascript("resource/js/jquery.treeview/lib/jquery.cookie.js");

        //-- load style
        //-- assign var
//        $sess_dokter = $this->session->userdata('session_dokter');
//        $session_peg_poli = $this->session->userdata('session_peg_poli');
//        $session_ad_obat = $this->session->userdata('session_ad_obat');
//        $this->smarty->assign("ses_dokter", $sess_dokter);
//        $this->smarty->assign("ses_peg_poli", $session_peg_poli);
//        $this->smarty->assign("ses_ad_obat", $session_ad_obat);
    }
    protected function baseViewApp() {
        $this->smarty->assign("arrConfig", $this->config);
        //-- display global link
        self::displayBaseLink();
        //-- display site title
        self::displaySiteTitle();
        //-- check security
    
        self::displayBreadcrumbNavigation();
        //-- display sidebar navigation
      
    }

    /*
     * Method layouting base document
     * diperbolehkan untuk dioverride pada class anaknya
     */

    protected function display($pStrTemplateName = 'base/pegawai/index.html') {
        // -- set template header and sidebar
        $this->smarty->assign("strTemplateHeader", "base/pegawai/header.html");
        $this->smarty->assign("strTemplateSidebar", "base/pegawai/sidebar.html");
        // set template
        $this->smarty->display($pStrTemplateName);
    }

    //-- base link
    private function displayBaseLink() {
        // logout
        $this->smarty->assign("strUrlLogout", site_url("login/loginpegawai/logoutProcess"));
    }

    //-- set site title
    private function displaySiteTitle() {
        $this->smarty->assign("strPageTitle", "CiSmart | Time Excelindo PHP Framework");
    }

    //-- set breadcrumb navigation
    private function displayBreadcrumbNavigation() {
        $strHtmlBreadcrumb = "<a href='" . base_url() . "/index.php/home/welcomepegawai'>Home</a>";
        $this->smarty->assign("strBreadcrumbUrl", $strHtmlBreadcrumb);
    }
    //-- set page rule
    protected function setPageRule($pStrRule) {
        if (!isset($this->arrRuleTp[$pStrRule]) || $this->arrRuleTp[$pStrRule] != '1') {
            redirect('home/adminforbidden');
        }
    }

    //-- clear login cache
    protected function clearCache() {
        header('Cache-Control: no-store, no-cache, must-revalidate');
        header('Cache-Control: post-check=0, pre-check=0', false);
        header('Pragma: no-cache');
    }

}